//
//  AddContactViewController.m
//  17-SandBoxHomeWork
//
//  Created by 曹曹 on 16/8/6.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "AddContactViewController.h"
#import "Contacts.h"

@interface AddContactViewController ()
@property (weak, nonatomic) IBOutlet UITextField *contactName;
@property (weak, nonatomic) IBOutlet UITextField *contactPhone;
@property (weak, nonatomic) IBOutlet UITextField *contactAddress;

@end

@implementation AddContactViewController
- (IBAction)addContact:(id)sender {
    Contacts *contact = [Contacts contactWithName:_contactName.text phone:_contactPhone.text address:_contactAddress.text avatar:@"0"];
    if (self.delegate && [self.delegate respondsToSelector:@selector(addContact:)]) {
        [self.delegate addContact:contact];
    }
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
